const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: ['全部', '待确认', '待入住', '已入住'],
    tabIndex: 0,
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      options: options
    })
    this.getAllList()
  },

  setTab: function (e) {
    console.log(e.currentTarget.dataset.index)
    this.setData({
      tabIndex: e.currentTarget.dataset.index
    })
  },
  backto: function () {
    wx.navigateBack({})
  },
  inHotel: function (e) {
    var that = this
    var id = e.currentTarget.dataset.id
    app.ihttpGet('https://www.58zltc.com/api.php/Hotel/confirmCheckIn/openid/' + app.globalData.openid + '/order_id/' + id, function (res) {
      var icon = 'none'
      res.data.error == 0 ? icon = 'success' : ''
      wx.showToast({
        title: res.data.msg,
        icon: icon,
        duration: 1200
      })
      setTimeout(function () {
        that.getAllList()
      }, 1200)
    });
  },
  //预定列表
  getAllList: function (options) {
    var that = this
    app.ihttpGet('https://www.58zltc.com/api.php/Hotel/getYuDing/openid/' + app.globalData.openid + '/shop_id/' + that.data.options.shop_id, function (res) {
      that.setData({
        list: res.data,
        shop_id: that.data.options.shop_id
      })
    });
    wx.hideLoading();
  }
})